package com.xcity.tools.sql;


import java.text.MessageFormat;
import java.util.List;

import com.xcity.game.recharge.RechargeTemplate;

import naga.x.App;
import naga.x.common.Config;
import naga.x.game.template.TemplateParser;
import naga.x.game.template.TemplateService;

public class RechargeTemplateSqlGen {

	static final String DIR_XLS = "C:/Users/yang.li/Desktop/server_release/data";
	
	public static void main(String[] args) throws Exception {
		TemplateService service = new TemplateService();
		App.getApp().setConfig(new Config());
		App.getApp().getServiceManager().add(service);
//		App.getApp().getConfig().put(Config.DATA_DIR, DIR_XLS);
		App.getApp().getConfig().dataDir = DIR_XLS;
		TemplateParser parser = new TemplateParser(service);
		parser.parse(RechargeTemplate.class);
		List<RechargeTemplate> list = service.getTemplatesList(RechargeTemplate.class);
		String sql = "INSERT INTO `recharge_template` VALUES(''{0}'', ''{1}'', ''{2}'', ''{3}'', ''{4}'', ''{5}'', ''{6}'', ''{7}'');\n";
		StringBuilder buf = new StringBuilder(1024);
		for (RechargeTemplate t : list) {
			String id = String.valueOf(t.getId());
			String type = String.valueOf(t.getType());
			String name = t.getName();
			String desc = t.getDesc();
			String icon = t.getIcon();
			String currency = t.getCurrency();
			String price = String.valueOf(t.getPrice());
			String stone = String.valueOf(t.getStone());
			buf.append(MessageFormat.format(sql, id, type, name, desc, icon, currency, price, stone));
		}
		System.out.println(buf);
	}
	
}
